import Vue from 'vue'
import VueRouter from 'vue-router'
import { getRouterInfo } from '@/api/addRouter'
import store from '@/store'
const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => {
    if (err.name !== 'NavigationDuplicated') throw err;
  });
};
Vue.use(VueRouter)





const routes = [
  {
    path: '/',
    name: 'login',
    component: () => import("@/views/login/index.vue"),
    meta: {
      title: "登录"
    }
  },
  {
    path: '/scanCodeLogin',
    name: 'scanCodeLogin',
    component: () => import("@/views/login/scanCodeLogin.vue"),
    meta: {
      title: "登录"
    }
  },
  
  // 账号注册
  {
    path: '/register/:id',
    name: 'register',
    component: () => import("@/views/register/index.vue"),
    meta: {
      title: "注册"
    }
  },
  // 忘记密码
  {
    path: '/forget/:id',
    name: 'forget',
    component: () => import("@/views/forget/index.vue"),
    meta: {
      title: "密码找回"
    }
  },
  // 填写申诉找回
  {
    path: '/appeal/:id',
    name: 'appeal',
    component: () => import("@/views/appeal/index.vue"),
    meta: {
      title: "填写申诉找回"
    }
  },
  // 短信验证找回
  {
    path: '/note',
    name: 'note',
    component: () => import("@/views/note/index.vue"),
    meta: {
      title: "短信验证找回"
    }
  },

  // 导航页
  {
    path: '/nav',
    name: 'nav',
    component: () => import("@/views/nav/index.vue"),
    meta: {
      title: "导航"
    },
    children: [
      // 我的
      {
        path: "my",
        name: 'my',
        component: () => import("@/views/nav/my/home/index.vue"),
        meta: {
          title: "我的"
        },
      },
      {
        path: "home",
        name: 'home',
        component: () => import("@/views/nav/home/index.vue"),
        meta: {
          title: "首页"
        },
      },
      // {
      //   path: 'ho',
      //   name: 'ho',
      //   component: () => import("@/views/nav/ho/index.vue"),
      //   meta: {
      //     title: "首页"
      //   }
      // },
      {
        path: 'evaluate',
        name: 'evaluate',
        component: () => import("@/views/nav/evaluate/home/index.vue"),
        meta: {
          title: "心理测评列表"
        }
      },



      // 预约咨询
      {
        path: 'consult',
        name: 'consult',
        component: () => import("@/views/nav/consult/home/index.vue"),
        meta: {
          title: "预约咨询"
        }
      },
      // 功能中心
      {
        path: 'functionCenter',
        name: 'functionCenter',
        component: () => import("@/views/nav/functionCenter/home/index.vue"),
        meta: {
          title: "功能中心"
        }
      },
    ]
  },
  {
    path: '/evaluteList',
    name: 'evaluteList',
    component: () => import("@/views/nav/evaluate/evaluteList/index.vue"),
    meta: {
      title: "心理测评列表"
    }
  },

  // 测评普通测评详情
  {
    path: '/normalEvaluateDetail/:sid/:tid/:trid/:count',
    name: 'normalEvaluateDetail',
    component: () => import("@/views/nav/evaluate/evaluateDetail/index.vue"),
    meta: {
      title: "测评量表详情"
    },
  },

  //团体测评详情
  {
    path: '/teamEvaluateDetail',
    name: 'teamEvaluateDetail',
    component: () => import("@/views/nav/evaluate/evaluateTeamDetail/index.vue"),
    meta: {
      title: "团体测评量表详情"
    },
  },
  // 个人测评
  {
    path: '/normalAnswer',
    name: 'normalAnswer',
    component: () => import("@/views/nav/evaluate/normalAnswer/index.vue"),
    meta: {
      title: "个人答题"
    },
  },
  // 团体测评
  {
    path: '/teamAnswer/:sid/:tid/:rid/:trid/:relevance_id/:factor_id',
    name: 'teamAnswer',
    component: () => import("@/views/nav/evaluate/teamAnswer/index.vue"),
    meta: {
      title: "团体测评"
    },
  },

  // 线上咨询
  {
    path: '/initiateConsultation',
    name: 'initiateConsultation',
    component: () => import("@/views/nav/consult/initiateConsultation/index.vue"),
    meta: {
      title: "线上咨询"
    },
  },
  // 发起咨询

  {
    path: '/launch',
    name: 'launch',
    component: () => import("@/views/nav/consult/launch/index.vue"),
    meta: {
      title: "发起线上咨询"
    },
  },
  // 线下预约
  {
    path: '/offlineAppointment',
    name: 'offlineAppointment',
    component: () => import("@/views/nav/consult/offlineAppointment/index.vue"),
    meta: {
      title: "线下预约"
    },
  },
  // 线下预约
  {
    path: '/launch2',
    name: 'launch2',
    component: () => import("@/views/nav/consult/launch2/index.vue"),
    meta: {
      title: "发起线下预约"
    },
  },
  {
    path: '/consultationRecord',
    name: 'consultationRecord',
    component: () => import("@/views/nav/consult/consultationRecord/index.vue"),
    meta: {
      title: "发起线下预约"
    },
  },
  // 预约成功！
  {
    path: '/subscribeSuccess',
    name: 'subscribeSuccess',
    component: () => import("@/views/nav/consult/success/index.vue"),
    meta: {
      title: "预约成功"
    },
  },



  // 线上咨询记录
  {
    path: '/consultationRecord',
    name: 'consultationRecord',
    component: () => import("@/views/nav/functionCenter/consultationRecord/index.vue"),
    meta: {
      title: "线上咨询记录"
    },
  },
  // 线上咨询记录详情
  {
    path: '/consultationRecordDetail',
    name: 'consultationRecordDetail',
    component: () => import("@/views/nav/consult/consultationRecord/consultationRecordDetail.vue"),
    meta: {
      title: "线上咨询记录详情"
    },
  },
  // 个人资料
  {
    path: '/personInfo',
    name: 'personInfo',
    component: () => import("@/views/nav/my/personInfo/index.vue"),
    meta: {
      title: "个人资料"
    },
  },
  // 管理登录方式
  {
    path: '/manageLogin',
    name: 'manageLogin',
    component: () => import("@/views/nav/my/manageLogin/index.vue"),
    meta: {
      title: "管理登录方式"
    },
  },
  // 修改登录密码
  {
    path: '/updatePwd',
    name: 'updatePwd',
    component: () => import("@/views/nav/my/updatePwd/index.vue"),
    meta: {
      title: "修改登录密码"
    },
  },
  // 消息列表
  {
    path: '/messageList',
    name: 'messageList',
    component: () => import("@/views/nav/my/messageList/index.vue"),
    meta: {
      title: "消息列表"
    },
  },
  // 消息详情
  {
    path: '/messageDetail',
    name: 'messageDetail',
    component: () => import("@/views/nav/my/messageDetail/index.vue"),
    meta: {
      title: "消息详情"
    },
  },

  // 用户档案
  {
    path: '/userRecord',
    name: 'userRecord',
    component: () => import("@/views/nav/functionCenter/userRecord/home/index.vue"),
    meta: {
      title: "用户档案"
    },
  },

  // 用户档案- 基本资料
  {
    path: '/baseData',
    name: 'baseData',
    component: () => import("@/views/nav/functionCenter/userRecord/baseData/index.vue"),
    meta: {
      title: "用户档案-基本资料"
    },
  },
  // 用户档案- 健康资料
  {
    path: '/health',
    name: 'health',
    component: () => import("@/views/nav/functionCenter/userRecord/health/index.vue"),
    meta: {
      title: "用户档案-健康资料"
    },
  },

  // 普通测评记录
  {
    path: '/evaluateRecord',
    name: 'evaluateRecord',
    component: () => import("@/views/nav/evaluate/evaluateRecord/normalEvaluateRecord/index.vue"),
    meta: {
      title: "普通测评记录"
    }
  },
  {
    path: '/taskRecord',
    name: 'taskRecord',
    component: () => import("@/views/nav/evaluate/evaluationRecord/taskRecord.vue"),
    meta: {
      title: "任务测评记录"
    }
  },

  {
    path: '/questionnaireRecord',
    name: 'questionnaireRecord',
    component: () => import("@/views/nav/evaluate/evaluationRecord/questionnaireRecord.vue"),
    meta: {
      title: "任务测评记录"
    }
  },


  {
    path: '/evaluationRecord',
    name: 'evaluationRecord',
    component: () => import("@/views/nav/evaluate/evaluationRecord/index.vue"),
    meta: {
      title: "普通测评记录"
    }
  },
  {
    path: '/taskDetails',
    name: 'taskDetails',
    component: () => import("@/views/nav/evaluate/evaluationDetails/taskDetails.vue"),
    meta: {
      title: "任务测评详情"
    }
  },
  {
    path: '/taskDetails',
    name: 'taskDetails',
    component: () => import("@/views/nav/evaluate/evaluationDetails/taskDetails.vue"),
    meta: {
      title: "问卷测评详情"
    }
  },
  {
    path: '/questionnaireDetails',
    name: 'questionnaireDetails',
    component: () => import("@/views/nav/evaluate/evaluationDetails/questionnaireDetails.vue"),
    meta: {
      title: "任务测评详情"
    }
  },
  {
    path: '/questionnaireAnswer',
    name: 'questionnaireAnswer',
    component: () => import("@/views/nav/evaluate/questionnaireAnswer/index.vue"),
    meta: {
      title: "任务测评详情"
    }
  },
  {
    path: '/questionnaireExport',
    name: 'questionnaireExport',
    component: () => import("@/views/nav/evaluate/evaluationDetails/questionnaireExport.vue"),
    meta: {
      title: "任务测评详情"
    }
  },
  
  // 咨询师详情
  {
    path: '/consultantInfo',
    name: 'consultantInfo',
    component: () => import("@/views/nav/consult/consultationRecord/consultantInfo.vue"),
    meta: {
      title: "咨询师详情"
    },
  },
  // 查看测评结果
  {
    path: '/testResult/:type/:id',
    name: 'testResult',
    component: () => import("@/views/nav/functionCenter/testResult/index.vue"),
    meta: {
      title: "查看测评结果"
    },
  },
  // 近况自评表
  {
    path: '/selfAssessment/:type/:id',
    name: 'selfAssessment',
    component: () => import("@/views/nav/functionCenter/selfAssessment/index.vue"),
    meta: {
      title: "近况自评表"
    },
  },
  // 线下预约记录
  // {
  //   path: '/appointmentRecord',
  //   name: 'appointmentRecord',
  //   component: () => import("@/views/nav/functionCenter/appointmentRecord/index.vue"),
  //   meta: {
  //     title: "线下预约记录"
  //   },
  // },
  // 赴约前置任务
  {
    path: '/appointmentPreTask',
    name: 'appointmentPreTask',
    component: () => import("@/views/nav/consult/consultationRecord/appointmentPreTask.vue"),
    meta: {
      title: "赴约前置任务"
    },
  },
  // 取消预约申请
  {
    path: '/cancelAppointment',
    name: 'cancelAppointment',
    component: () => import("@/views/nav/consult/consultationRecord/cancelAppointment.vue"),
    meta: {
      title: "取消预约申请"
    },
  },
  {
    path: '/appointmentDetails',
    name: 'appointmentDetails',
    component: () => import("@/views/nav/consult/consultationRecord/appointmentDetails.vue"),
    meta: {
      title: "预约记录详情"
    },
  },


  // 查看测评结果
  {
    path: '/evaluateExport',
    name: 'evaluateExport',
    component: () => import("@/views/nav/evaluate/evaluateExport/index.vue"),
    meta: {
      title: "查看测评结果"
    },
  },
  {
    path: '/questionnaireResults',
    name: 'questionnaireResults',
    component: () => import("@/views/nav/evaluate/evaluateExport/questionnaireResults.vue"),
    meta: {
      title: "问卷测评结果"
    },
  },
  // 团体测评报告
  {
    path: '/teamEvaluateExport',
    name: 'teamEvaluateExport',
    component: () => import("@/views/nav/evaluate/teamEvaluateExport/index.vue"),
    meta: {
      title: "团体测评报告列表"
    },
  },
  {
    path: '/teamEvaluateExportDetail/:id/:tid',
    name: 'teamEvaluateExportDetail',
    component: () => import("@/views/nav/evaluate/teamEvaluateExportDetail/index.vue"),
    meta: {
      title: "团体测评报告详情"
    }
  },
  // 预约记录详情
  // {
  //   path: '/appointmentRecordDetail/:id',
  //   name: 'appointmentRecordDetail',
  //   component: () => import("@/views/nav/functionCenter/appointmentRecordDetail/index.vue"),
  //   meta: {
  //     title: "预约记录详情"
  //   },
  // },
  // 编辑教育情况
  {
    path: '/education',
    name: 'education',
    component: () => import("@/views/nav/functionCenter/userRecord/education/index.vue"),
    meta: {
      title: "预约记录详情"
    },
  },
  // 编辑残障等级
  {
    path: '/disability',
    name: 'disability',
    component: () => import("@/views/nav/functionCenter/userRecord/disability/index.vue"),
    meta: {
      title: "编辑残障等级"
    },
  },
  // 编辑家庭情况
  {
    path: '/family',
    name: 'family',
    component: () => import("@/views/nav/functionCenter/userRecord/family/index.vue"),
    meta: {
      title: "编辑家庭情况"
    },
  },
  // 编辑家庭访谈
  {
    path: '/familyInterview',
    name: 'familyInterview',
    component: () => import("@/views/nav/functionCenter/userRecord/familyInterview/index.vue"),
    meta: {
      title: "编辑家庭访谈"
    },
  },
  // 精神状态编辑
  {
    path: '/mentalState',
    name: 'mentalState',
    component: () => import("@/views/nav/functionCenter/userRecord/mentalState/index.vue"),
    meta: {
      title: "编辑精神状态"
    },
  },
  // 心理视频
  {
    path: '/psychologicalVideo',
    name: 'psychologicalVideo',
    component: () => import("@/views/nav/functionCenter/psychologicalVideo/index.vue"),
    meta: {
      title: "心理视频"
    },
  },
  {
    path: '/video',
    name: 'video',
    component: () => import("@/views/nav/functionCenter/psychologicalVideo/video.vue"),
    meta: {
      title: "视频播放"
    },
  },
  {
    path: '/psychologicalMusic',
    name: 'psychologicalMusic',
    component: () => import("@/views/nav/functionCenter/psychologicalMusic/index.vue"),
    meta: {
      title: "心理音乐"
    },
  },
  {
    path: '/playMusic',
    name: 'playMusic',
    component: () => import("@/views/nav/functionCenter/psychologicalMusic/playMusic.vue"),
    meta: {
      title: "正在播放"
    },
  },

  {
    path: '/psychologicalPicture',
    name: 'psychologicalPicture',
    component: () => import("@/views/nav/functionCenter/psychologicalPicture/index.vue"),
    meta: {
      title: "心理图片"
    },
  },
  {
    path: '/pictureBrowse',
    name: 'pictureBrowse',
    component: () => import("@/views/nav/functionCenter/psychologicalPicture/pictureBrowse.vue"),
    meta: {
      title: "图片展示"
    },
  },
  {
    path: '/psychologicalArticle',
    name: 'psychologicalArticle',
    component: () => import("@/views/nav/functionCenter/psychologicalArticle/index.vue"),
    meta: {
      title: "心理文章"
    },
  },
  {
    path: '/articleDetails',
    name: 'articleDetails',
    component: () => import("@/views/nav/functionCenter/psychologicalArticle/articleDetails.vue"),
    meta: {
      title: "文章详情"
    },
  },
  {
    path: '/game',
    name: 'game',
    component: () => import("@/views/nav/functionCenter/game/index.vue"),
    meta: {
      title: "小游戏"
    },
  },
  {
    path: '/crisisReport',
    name: 'crisisReport',
    component: () => import("@/views/nav/functionCenter/crisisReport/index.vue"),
    meta: {
      title: "危机上报"
    },
  },
  {
    path: '/wisdomTree',
    name: 'wisdomTree',
    component: () => import("@/views/nav/functionCenter/wisdomTree/index.vue"),
    meta: {
      title: "心理智慧树"
    },
  },
  {
    path: '/sendReceiveRecord',
    name: 'sendReceiveRecord',
    component: () => import("@/views/nav/functionCenter/wisdomTree/sendReceiveRecord.vue"),
    meta: {
      title: "收发记录"
    },
  },
  {
    path: '/recordDetails',
    name: 'recordDetails',
    component: () => import("@/views/nav/functionCenter/wisdomTree/recordDetails.vue"),
    meta: {
      title: "记录详情"
    },
  },
  {
    path: '/anonymityInfo',
    name: 'anonymityInfo',
    component: () => import("@/views/nav/functionCenter/wisdomTree/anonymityInfo.vue"),
    meta: {
      title: "匿名信息设置"
    },
  },
  {
    path: '/apply',
    name: 'apply',
    component: () => import("@/views/nav/functionCenter/wisdomTree/apply.vue"),
    meta: {
      title: "查看实名申请"
    },
  },
  {
    path: '/trainingLecture',
    name: 'trainingLecture',
    component: () => import("@/views/nav/functionCenter/trainingLecture/index.vue"),
    meta: {
      title: "培训讲座"
    },
  },
  {
    path: '/lecturedetails',
    name: 'lecturedetails',
    component: () => import("@/views/nav/functionCenter/trainingLecture/lecturedetails.vue"),
    meta: {
      title: "培训讲座报名详情"
    },
  },
  {
    path: '/lectureReport',
    name: 'lectureReport',
    component: () => import("@/views/nav/functionCenter/trainingLecture/lectureReport.vue"),
    meta: {
      title: "查看测评结果"
    },
  },


  {
    path: '/activityDetails',
    name: 'activityDetails',
    component: () => import("@/views/nav/functionCenter/groupActivity/activityDetails.vue"),
    meta: {
      title: "团体活动"
    },
  },
  {
    path: '/activityReport',
    name: 'activityReport',
    component: () => import("@/views/nav/functionCenter/groupActivity/activityReport.vue"),
    meta: {
      title: "团体活动"
    },
  },
  {
    path: '/historicalDetails',
    name: 'historicalDetails',
    component: () => import("@/views/nav/functionCenter/trainingLecture/historicalDetails.vue"),
    meta: {
      title: "历史活动详情"
    },
  },
  {
    path: '/groupActivity',
    name: 'groupActivity',
    component: () => import("@/views/nav/functionCenter/groupActivity/index.vue"),
    meta: {
      title: "团体活动"
    },
  },
  {
    path: '/applyVacate',
    name: 'applyVacate',
    component: () => import("@/views/nav/functionCenter/applyVacate/index.vue"),
    meta: {
      title: "申请请假"
    },
  },
  {
    path: '/historyActivityDetails',
    name: 'historyActivityDetails',
    component: () => import("@/views/nav/functionCenter/groupActivity/historyActivityDetails.vue"),
    meta: {
      title: ""
    },
  },
  {
    path: '/psychologySchool',
    name: 'psychologySchool',
    component: () => import("@/views/nav/functionCenter/psychologySchool/index.vue"),
    meta: {
      title: ""
    },
  },
  {
    path: '/courseDetails',
    name: 'courseDetails',
    component: () => import("@/views/nav/functionCenter/psychologySchool/courseDetails.vue"),
    meta: {
      title: "课程详情"
    },
  },
  {
    path: '/chapterDet',
    name: 'chapterDet',
    component: () => import("@/views/nav/functionCenter/psychologySchool/chapterDet.vue"),
    meta: {
      title: "课程章节详情"
    },
  },
  {
    path: '/evaluationList',
    name: 'evaluationList',
    component: () => import("@/views/nav/evaluate/evaluationList/index.vue"),
    meta: {
      title: "任务测评/问卷测评"
    },
  },
  {
    path: '/taskList',
    name: 'taskList',
    component: () => import("@/views/nav/evaluate/evaluationList/taskList.vue"),
    meta: {
      title: "任务测评"
    },
  },
  {
    path: '/codeTaskList',
    name: 'codeTaskList',
    component: () => import("@/views/nav/evaluate/evaluationList/codeTaskList.vue"),
    meta: {
      title: "任务测评"
    },
  },
  {
    path: '/questionnaireList',
    name: 'questionnaireList',
    component: () => import("@/views/nav/evaluate/evaluationList/questionnaireList.vue"),
    meta: {
      title: "问卷测评"
    },
  },
  // packageSerial
  {
    path: '/packageSerial',
    name: 'PackageSerial',
    component: () => import("@/views/packageSerial/index.vue"),
    meta: {
      title: "扫码"
    },
  },

]




const router = new VueRouter({
  mode: 'hash',
  base: process.env.BASE_URL,
  routes
})




// getRouterInfo().then(({ data }) => {

//   let temp = data.data;

//   store.commit('SET_COMPANY_LIST', temp);
//   temp.forEach(item => {
//     const r = {
//       path: '/' + item.routing_address,
//       name: item.routing_address,
//       component: () => import("@/views/login/index.vue"),
//       meta: {
//         ...item
//       }
//     };
//     router.addRoute(r)
//   });

// });



export default router
